#ifndef JSONTEST_H
#define JSONTEST_H
#include <string>
#include <variant>
#include "nlohmann/json.hpp"
#include "jsonwrapper.h"

namespace jsontest
{
    //{"age":10,"name":"hxj","numbs":[1,2,3,4]}
    struct Person{
        std::string name;
        int age;
        std::vector<int> numbs;

        NLOHMANN_DEFINE_TYPE_INTRUSIVE(Person, name, age, numbs)
    };


    //{"age":10,"name":"hxj","numbs":[{"score":15.0,"subject":"yuwen"},{"score":15.0,"subject":"su"}]}
    class Subject{
    public:
        std::string subject;
        double score;

        NLOHMANN_DEFINE_TYPE_INTRUSIVE(Subject, subject, score)
    };
    class Person2{
    public:
        std::string name;
        int age;
        std::list<Subject> numbs;

        NLOHMANN_DEFINE_TYPE_INTRUSIVE(Person2, name, age, numbs)
    };


    class GrpcEventJsonAvis{
    public:
        std::string SourceId;
        std::string TargetId;
        std::string EventName;

        //....其他内容
        nlohmann::json param;

        //std::vector<std::variant<>> Parameters; //TODO

        NLOHMANN_DEFINE_TYPE_INTRUSIVE(GrpcEventJsonAvis, SourceId, TargetId, EventName, param)
    };

    class GrpcEventJsonAvisSub{
    public:
        std::string name;
        int age;

        NLOHMANN_DEFINE_TYPE_INTRUSIVE(GrpcEventJsonAvisSub,name, age)
    };

    class JsonTest
    {
    public:
        JsonTest();


        // 序列化为 JSON
        std::string SerializeAsString();

        void ParseFromString(const std::string& json);
    };
}



#endif // JSONTEST_H
